﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ICM_Master_Warehouse.aspx.cs" Inherits="KPIS.GERP.GIMS.APP.APP_UI.Add_Form.ICM_Master_Warehouse" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register TagPrefix="custom" Namespace="KPIS.Customs.UI" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title></title>
    <LINK REL="StyleSheet" HREF="../../Styles/StyleSheet.css" TYPE="text/css">  
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" >
        </asp:ScriptManager>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function onTextChangeGeneral(sender) {
                    if (sender.get_value() == "") {
                        sender.set_text("");
                    }
                }

                var cancelDropDownClosing = false;

                function StopPropagation(e) {
                    e.cancelBubble = true;
                    if (e.stopPropagation) {
                        e.stopPropagation();
                    }
                }

                function OnClientDropDownClosingHandler(sender, e) {
                    e.set_cancel(cancelDropDownClosing);
                }

                function OnClientNodeClickingHandler(sender, e) {
                    var node = e.get_node();
                    if (node.get_category() == "Type") {
                        node.toggle();
                    }
                    else {
                        var combo = $find('<%= cbJobSite.ClientID %>');
                        combo.set_text(node.get_text());
                        cancelDropDownClosing = false;
                        combo.hideDropDown();
                    }
                }

                function onTextChange(sender) {
                    var tree = $find('<%= ((RadTreeView)((RadComboBox)cbJobSite).Items[0].FindControl("TreeViewJobSite")).ClientID %>');
                    var node = tree.findNodeByText(sender.get_text());
                    if (node == null) {
                        sender.set_text("");
                    }
                }

                function ChangeTab(value, page_index) {
                    Page_ClientValidate();
                    if (Page_IsValid) {
                        var tabStrip = $find("<%= RadTabStrip1.ClientID %>");
                        var pageView = $find("<%= RadMultiPage1.ClientID %>");
                        var tab = tabStrip.findTabByValue(value);
                        var pageViewIndex = page_index;
                        tab.set_selected(true);
                        pageView.get_pageViews().getPageView(pageViewIndex).set_selected(true);
                    }
                }

                function GetRadWindow() {
                    var oWindow = null;
                    if (window.radWindow)
                        oWindow = window.RadWindow; //Will work in Moz in all cases, including clasic dialog      
                    else if (window.frameElement.radWindow)
                        oWindow = window.frameElement.radWindow; //IE (and Moz as well)      
                    return oWindow;
                }

                function CloseWindow() {
                    GetRadWindow().Close();
                }          
            </script>
        </telerik:RadCodeBlock>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None" Skin="Outlook">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxManager runat="server" ID="RadManager1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="nextButton_Detail">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="nextButton_Detail" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="panelCommand_JobSite">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="panelDetail_JobSite" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
    
        <asp:Panel ID="panelHidden" runat="server">
            <asp:HiddenField ID="hdSeq" runat="server" Value="" />
        </asp:Panel>
        
        <asp:Panel ID="panelAll" runat="server">
            <div class="exampleWrapper">
                <telerik:RadTabStrip ID="RadTabStrip1" SelectedIndex="0" runat="server" MultiPageID="RadMultiPage1" Skin="Vista" CssClass="multiPage">
                    <Tabs>
                        <telerik:RadTab runat="server" Text="รายละเอียดคลังพัสดุ" Selected="true" Value="Detail">
                        </telerik:RadTab>
                        <telerik:RadTab runat="server" Text="หน่วยงานเบิกจ่าย" Value="JobSite">
                        </telerik:RadTab>
                    </Tabs>
                </telerik:RadTabStrip>
                <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" CssClass="pageView">
                    <telerik:RadPageView ID="RadPageView1" runat="server">
                        <asp:Panel ID="panelDetail" runat="server">
                            <div class="bigModuleRight" align="left">
                                <div class="bigModuleBottomRight">
                                    <asp:Panel ID="panelHeaderList" runat="server">
                                        <div class="header-grid">
                                            <asp:Label ID="lblHeaderList" runat="server" Text="รายละเอียดคลังพัสดุ"></asp:Label>
                                        </div>
                                    </asp:Panel>
                                    <asp:Panel CssClass="panelList" runat="server" ID="panelList" ScrollBars="Auto">
                                        <table width="98%">
                                            <tr>
                                                <td width="650px" valign="top">
                                                    <ul class="formList" id="Ul1">  
                                                        <div class="formList-detail">
                                                            <table>
                                                                <tr>
                                                                    <td width = "150px" valign="top">
                                                                        ประเภท :
                                                                    </td>
                                                                    <td>
                                                                        <telerik:RadComboBox CssClass="RadComboBox" runat="server" ID="cbScope" AllowCustomText="true" ShowDropDownOnTextboxClick="true"
                                                                            Filter="Contains" DataTextField="Name" DataValueField="Seq" Width="150px" Height="60px"
                                                                            EmptyMessage=".. พิมพ์ที่นี่เพื่อช่วยค้นหา .." LoadingMessage="กำลังโหลดข้อมูล ..." MarkFirstMatch="false" 
                                                                            OnClientTextChange="onTextChangeGeneral">
                                                                        </telerik:RadComboBox>
                                                                        &nbsp;<label id="Label1" runat="server"><font color="red">*</font></label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                    </td>
                                                                    <td>
                                                                        <asp:RequiredFieldValidator ID="ValcbScope" runat="server" ControlToValidate="cbScope" SetFocusOnError="True" Display="Dynamic" ErrorMessage="* กรุณาระบุประเภท *"></asp:RequiredFieldValidator>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                        <div class="formList-detail">
                                                            <table>
                                                                <tr>
                                                                    <td width = "150px">
                                                                        ชื่อ :
                                                                    </td>
                                                                    <td>
                                                                        <asp:TextBox CssClass="TextBox" ID="txtName" runat="server" Width="280px"></asp:TextBox>
                                                                        <label id="Label2" runat="server"><font color="red">*</font></label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                    </td>
                                                                    <td>
                                                                        <asp:RequiredFieldValidator ID="ValtxtName" runat="server" ControlToValidate="txtName" SetFocusOnError="True" Display="Dynamic" ErrorMessage="* กรุณาระบุชื่อ *"></asp:RequiredFieldValidator>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </div>        
                                                        <div class="formList-detail">
                                                            <table>
                                                                <tr>
                                                                    <td width = "150px" valign="top">
                                                                        หน่วยงานรับผิดชอบ :
                                                                    </td>
                                                                    <td>
                                                                        <telerik:RadComboBox CssClass="RadComboBox" ID="cbJobSite" Runat="server" Skin="Outlook" Width="260px" Height="300px"
                                                                        AllowCustomText="true" ShowDropDownOnTextboxClick="true" EmptyMessage=".. กรุณาเลือกหน่วยงาน .." 
                                                                        LoadingMessage="กำลังโหลดข้อมูล ..." MarkFirstMatch="false"
                                                                        OnClientTextChange="onTextChange" OnClientDropDownClosing="OnClientDropDownClosingHandler">
                                                                            <ItemTemplate>
                                                                                <div onclick="StopPropagation(event)">
                                                                                    <telerik:RadTreeView CssClass="TreeView" ID="TreeViewJobSite" runat="server" Skin="Outlook" MultipleSelect="false"
                                                                                    DataTextField="Name" DataValueField="Id" DataFieldID="Id" DataFieldParentID="Parent_id"
                                                                                    OnClientNodeClicking="OnClientNodeClickingHandler">
                                                                                        <DataBindings>
                                                                                            <telerik:RadTreeNodeBinding Depth="0" Category="Type" />
                                                                                        </DataBindings>
                                                                                    </telerik:RadTreeView>
                                                                                </div>
                                                                            </ItemTemplate>
                                                                            <Items>
                                                                                <telerik:RadComboBoxItem />
                                                                            </Items>
                                                                        </telerik:RadComboBox>
                                                                        <label id="Label4" runat="server"><font color="red">*</font></label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                    </td>
                                                                    <td>
                                                                        <asp:RequiredFieldValidator ID="ValcbJobsite" runat="server" ControlToValidate="cbJobsite" SetFocusOnError="True" Display="Dynamic" ErrorMessage="* กรุณาระบุหน่วยงานรับผิดชอบ *"></asp:RequiredFieldValidator>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </div> 
                                                        <div class="formList-detail">
                                                            <table>
                                                                <tr>
                                                                    <td width = "150px" valign="top">
                                                                        รายละเอียด :
                                                                    </td>
                                                                    <td>
                                                                        <asp:TextBox CssClass="TextBox" ID="txtDescr" runat="server" TextMode="MultiLine" Height="100" Width="280px"></asp:TextBox>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                    </ul>
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                </div>
                            </div>
                            <asp:Panel ID="panelTool" runat="server">
                                <div class="bigModuleRight">
                                    <div class="bigModuleBottomRight">
                                        <table width="100%">
                                            <tr class="command-list">
                                                <td align="right">
                                                    <asp:LinkButton ID="nextButton_Detail" runat="server" OnClientClick="javascript:ChangeTab('JobSite',1);">
                                                        <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Button/next_button.png" />
                                                    </asp:LinkButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>        
                            </asp:Panel>
                        </asp:Panel>
                    </telerik:RadPageView>
                    <telerik:RadPageView ID="RadPageView2" runat="server">
                        <asp:Panel ID="panelDetail_JobSite" runat="server">
                            <table style="width: 98%;" cellpadding="0" cellspacing="0">
                                <tr valign="top">
                                    <td valign="top">
                                        <asp:Panel ID="panelCommand_JobSite" runat="server">
                                            <div class="bigModuleRight">
                                                <div class="bigModuleBottomRight">
                                                    <table>
                                                        <tr class="command-list">
                                                            <td class="command-item" style="border: none">
                                                                <asp:LinkButton ID="ShowGrid_JobSite" runat="server" CssClass="LinkButton" CausesValidation="false" OnClick="ShowGrid_JobSite_Click">
                                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/table.gif" />&nbsp;&nbsp;แสดงข้อมูลทั้งหมด
                                                                </asp:LinkButton>                        
                                                            </td>
                                                            <td class="command-item">
                                                                <asp:LinkButton ID="AddNew_JobSite" runat="server" CssClass="LinkButton" OnClick="AddNew_JobSite_Click">
                                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/AddRecord.gif" />&nbsp;&nbsp;เพิ่มข้อมูลใหม่
                                                                </asp:LinkButton>
                                                            </td>
                                                            <td class="command-item">
                                                                <asp:LinkButton ID="AddNewSave_JobSite" runat="server" CssClass="LinkButton" Visible="false" OnClick="AddNewSave_JobSite_Click">
                                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cmd_Save.gif" />&nbsp;&nbsp;บันทึกข้อมูล
                                                                </asp:LinkButton>
                                                            </td>
                                                            <td class="command-item">
                                                                <asp:LinkButton ID="Delete_JobSite" runat="server" CssClass="LinkButton" OnClientClick="javascript:return confirm('ยืนยันการลบข้อมูลที่เลือก')" OnClick="Delete_JobSite_Click">
                                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Delete.gif" />&nbsp;&nbsp;ลบข้อมูล
                                                                </asp:LinkButton>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </div>
                                            </div>        
                                        </asp:Panel>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Panel ID="panelData_JobSite" runat="server">
                                            <div class="bigModuleRight">
                                                <div class="bigModuleBottomRight">
                                                    <asp:Panel ID="panelHeaderList1" runat="server">
                                                        <div class="header-grid">
                                                            <asp:Label ID="Label3" runat="server" Text="หน่วยงานเบิกจ่าย"></asp:Label>
                                                        </div>
                                                    </asp:Panel>
                                                    <asp:Panel CssClass="panelList" runat="server" ID="panelList_JobSite" ScrollBars="Auto">
                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <telerik:RadTreeView CssClass="TreeView" runat="server" ID="JobsiteTree" Skin="Outlook" 
                                                                    DataFieldID="Id" DataTextField="Name" DataFieldParentID="Parent_id" DataValueField="Id"
                                                                    CheckChildNodes="true" TriStateCheckBoxes="true" CheckBoxes="true" Width="550">
                                                                        <CollapseAnimation Duration="0" Type="None" />
                                                                        <ExpandAnimation Duration="0" Type="None" />
                                                                        <DataBindings>
                                                                            <telerik:RadTreeNodeBinding ImageUrlField="Image_url" />
                                                                        </DataBindings>
                                                                    </telerik:RadTreeView>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </asp:Panel>
                                                    <asp:Panel CssClass="panelGrid" ID="panelGrid_JobSite" runat="server" ScrollBars="Auto" Visible="true">
                                                        <div align="center">
                                                            <telerik:RadGrid CssClass="RadGrid" ID="Grid_JobSite" runat="server" AllowFilteringByColumn="true"
                                                            AllowMultiRowSelection="True" AllowPaging="false" AllowSorting="True"
                                                            AutoGenerateColumns="False" EnableAJAX="True"  PageSize="8"
                                                            GridLines="None" ShowStatusBar="false" Skin="Outlook" Width="95%"
                                                            OnItemCommand="Grid_JobSite_ItemCommand">
                                                                <MasterTableView GroupLoadMode="Client" AllowMultiColumnSorting="true" Width="100%" NoMasterRecordsText="<div align=center><font color=gray><i>ไม่มีข้อมูล</i></font></div>">
                                                                    <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                                                                    <GroupHeaderItemStyle HorizontalAlign="Left" />
                                                                    <Columns>
                                                                        <custom:CustomClientSelectColumn UniqueName="ClientSelectColumn">
                                                                            <HeaderStyle Width="20px" HorizontalAlign="Center" />
                                                                            <ItemStyle HorizontalAlign="Center" />
                                                                            <FilterTemplate> 
                                                                                <asp:LinkButton ID="clearFilter" runat="server" ToolTip="ยกเลิกการค้นหา" OnClick="clearFilter_Click">
                                                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cancel.gif" />
                                                                                </asp:LinkButton>
                                                                            </FilterTemplate> 
                                                                        </custom:CustomClientSelectColumn>
                                                                        <telerik:GridBoundColumn DataField="InfoJobSite.InfoScope.Name"
                                                                            GroupByExpression="InfoJobSite.InfoScope.Name Group By InfoJobSite.InfoScope.Seq" Groupable="true" Visible="false"
                                                                            AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false"
                                                                            FilterControlWidth="100%" HeaderText="ประเภทหน่วยงาน" 
                                                                            UniqueName="InfoJobSite.InfoScope.Name">
                                                                            <HeaderStyle HorizontalAlign="Center" />
                                                                            <ItemStyle HorizontalAlign="Left" />
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="InfoJobSite.Name" 
                                                                            AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false"
                                                                            FilterControlWidth="100%"
                                                                            HeaderStyle-HorizontalAlign="Center" HeaderText="ชื่อหน่วยงาน" 
                                                                            UniqueName="InfoJobSite.Name">
                                                                            <HeaderStyle HorizontalAlign="Center" />
                                                                            <ItemStyle HorizontalAlign="Left" />
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="InfoJobSite.Seq" 
                                                                            HeaderStyle-HorizontalAlign="Center" UniqueName="InfoJobSite.Seq" 
                                                                            Visible="false">
                                                                            <HeaderStyle HorizontalAlign="Center" />
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="InfoJobSite.InfoScope.Seq" 
                                                                            HeaderStyle-HorizontalAlign="Center" UniqueName="InfoJobSite.InfoScope.Seq" 
                                                                            Visible="false">
                                                                            <HeaderStyle HorizontalAlign="Center" />
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="InfoRecord.InfoStatus.Status" 
                                                                            HeaderStyle-HorizontalAlign="Center" UniqueName="InfoRecord.InfoStatus.Status" Visible="false">
                                                                            <HeaderStyle HorizontalAlign="Center" />
                                                                        </telerik:GridBoundColumn>
                                                                    </Columns>
                                                                </MasterTableView>
                                                                <ClientSettings EnableRowHoverStyle="true" >
                                                                    <Selecting AllowRowSelect="True" />
                                                                </ClientSettings>
                                                            </telerik:RadGrid>
                                                        </div>
                                                        <br />
                                                    </asp:Panel>
                                                </div>
                                            </div>
                                        </asp:Panel>
                                        <asp:Panel ID="panelTool_JobSite" runat="server">
                                            <div class="bigModuleRight">
                                                <div class="bigModuleBottomRight">
                                                    <table width="100%">
                                                        <tr class="command-list">
                                                            <td align="left">
                                                                <asp:LinkButton ID="backButton_JobSite" runat="server" OnClientClick="javascript:ChangeTab('Detail',0);">
                                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Button/back_button.png" />
                                                                </asp:LinkButton>
                                                            </td>
                                                            <td align="right">
                                                                <asp:LinkButton ID="finishButton_JobSite" runat="server" OnClick="finishButton_JobSite_Click" OnClientClick="javascript:return confirm('ยืนยันการบันทึกข้อมูล');">
                                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Button/finish_button.png" />
                                                                </asp:LinkButton>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </div>
                                            </div>        
                                        </asp:Panel>
                                    </td>
                                </tr>
                            </table>
                        </asp:Panel>
                    </telerik:RadPageView>
                </telerik:RadMultiPage>
            </div>
        </asp:Panel>
    </form>
</body>
</html>

